<?php $this->load->view("admin/$adminCurrentTemplate/commonHead2");?>
<table width="99%" border="0" cellspacing="1" cellpadding="0"
	class="editFormContainer">
	<form id="editForm" name="editForm" method="post"
		action="<?=$this->input->server('REQUEST_URI')?>"><input type="hidden"
		name="id" id="id" value="<?php if(isset($id)) echo $id; ?>" />
	<tr>
		<td class="guid">启用状态：</td>
		<td class="formItem"><input type="radio" name="disabled"
			id="disabled-0" value="0" checked="checked" /><label for="disabled-0"
			<?php if(isset($disabled)) if($disabled==0) echo ' checked' ;?>>启用</label> <input
			type="radio" name="disabled" id="disabled-1" value="1"
			<?php if(isset($disabled)) if($disabled==1) echo ' checked' ;?> /><label for="disabled-1">禁用</label>
		</td>
	</tr>
	<tr>
		<td class="guid">上级菜单：</td>
		<td class="formItem">
		<select name="parentId" id="parentId" size="1" class="single-select">
			<option value="0"<?php if(strlen($parentId)==0) echo " selected='selected'"?>>顶级菜单</option><?php 
		$str = '';
		foreach ($adminMenuAll as $value){
			$str .= "<option value=\"".$value->id."\"";
			if($value->id==$parentId){
				$str .= " selected=\"selected\"";
			}
			$str .=">";
			for($i=0;$i<$value->deep;$i++){
				$str .= "&nbsp;|-";
			}
			$str .= $value->title."</option>\n";
		}
		echo $str;
		?></select></td>
	</tr>
	<tr>
		<td class="guid">菜单名称：</td>
		<td class="formItem"><input type="text" name="title" id="title" class="sing-line input-name" value="<?php if(isset($title)) echo $title;?>" /></td>
	</tr>
	<tr>
		<td class="guid">标 识 符：</td>
		<td class="formItem"><input type="text" name="identifier" id="identifier" class="sing-line input-name" value="<?php if(isset($identifier)) echo $identifier;?>" /></td>
	</tr>
	<tr>
		<td class="guid">链接地址：</td>
		<td class="formItem">
			<input type="text" class="sing-line input-name" name="url" id="url" value="<?php if(isset($url)) echo $url;?>" />
		</td>
	</tr>
	</form>
</table>
<?php $this->load->view("admin/$adminCurrentTemplate/commonFoot2");?>
<script type="text/javascript">
var tvName = '<?php if(isset($tvName)) echo $tvName;?>';
$(function(){
	$('#title').bind('blur',titleBlur);
	dg.addBtn('subBtn','提 交',subForm);
	if($('#id').val().length!=0){
		$('#parentId option[value="' + $('#id').val() + '"]').remove();
	}else{
		dg.SetTitle('添加系统后台菜单');
	}
})

var titleBlur = function(){
	var id = $.trim($('#id').val());
	var parentId = $.trim($('#parentId').val());
	var title = $.trim($('#title').val());
	$.ajax({
		type:'POST',
		url:getInfo + '/check/',
		data:'tvName=' + tvName + '&parentIdOrCategoryIdFieldName=parentId&parentIdOrCategoryIdFieldValue=' + parentId + '&fieldName=title&fieldValue=' + title + '&id=' + id,
		success:function(returnValue){
			if(parseInt(returnValue)>0){
				subMess(218,108,'名称错误','<span class="red">对不起，菜单名称已经存在！</span>',$("#title"));
				return false;
			}
		}
	});
}

var subForm = function(){
	var id = $.trim($('#id').val());
	var disabled = $.trim($('#disabled').val());
	var title = $.trim($('#title').val());
	if(title.length==0){
		subMess(208,108,'名称错误','<span class="red">对不起，请输入菜单名称！</span>',$("#title"));
		return false;
	}
	$('#editForm').submit();
}
</script>
